/*
	File:		Game.h
	Course:		SGP 1302
	Author:		Jmullens
	Purpose:	CGame class controls the SGD Wrappers
				and the game state machine
*/


#pragma once
#include <vector>

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>


////////////////////////////////////////////////////
// SGD Wrappers
//	- forward declarations reduce header dependencies
//	- can ONLY make pointers & references to the type
class CSGD_Direct3D;
class CSGD_DirectInput;
class CSGD_TextureManager;
class CSGD_XAudio2;


// Game state
class IGameState;



////////////////////////////////////////////////////
// CGame class
//	- singleton object
//	- manages the wrappers
//	- game state machine
class CGame
{
public:
	////////////////////////////////////////////////
	// SINGLETON
	//	- only ONE instance can be created
	static	CGame*	GetInstance( void );
	static	void	DeleteInstance( void );

	
	////////////////////////////////////////////////
	// Setup:
	void Initialize( HWND hWnd, HINSTANCE hInstance, 
					 int nWidth, int nHeight,
					 bool bWindowed );

	// Play:
	bool Main( void );


	// Cleanup:
	void Shutdown( void );

	
	////////////////////////////////////////////////
	// Game State Machine:
	void ChangeState( IGameState* pNewState );
	void AddState( IGameState* pNewState );
	void PopState();


	// ACCESSORS
	int	GetWidth	( void ) const	{	return m_nScreenWidth;	}
	int GetHeight	( void ) const	{	return m_nScreenHeight;	}

	bool	GetWindow( void )		{	return m_bIsWindowed;	}
	void	SetWindow( bool b );


private:
	////////////////////////////////////////////////
	// SINGLETON
	//	- static data member for dynamically-allocated instance
	//	- hidden constructors / destructor / operator=
	static	CGame*	s_Instance;
	CGame( void );
	~CGame( void );
	CGame( const CGame& );				// copy constructor
	CGame& operator= ( const CGame& );	// assignment operator

	
	////////////////////////////////////////////////
	// Helper methods
	bool Input( void );
	void Update( void );
	void Render( void );

	
	////////////////////////////////////////////////
	// SGD Wrappers
	CSGD_Direct3D*			m_pD3D;
	CSGD_DirectInput*		m_pDI;
	CSGD_TextureManager*	m_pTM;
	CSGD_XAudio2*			m_pXA;

	// Window Attributes
	int						m_nScreenWidth;
	int						m_nScreenHeight;
	bool					m_bIsWindowed;
	int						m_nCursorID;

	//Current Time
	DWORD					m_dwCurrTime;


	// Current game state
	std::vector<IGameState*>	m_pCurrStates;
	int							m_nStateIndex;
};


